import com.itheima.utils.DateUtils;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class PasswordEncoding {
      @Autowired
      private  BCryptPasswordEncoder passwordEncoder;

    @Test
    public void passwordEncoding(){
        passwordEncoder = new BCryptPasswordEncoder();
        String encode = passwordEncoder.encode("123");
        boolean matches = passwordEncoder.matches("$2a$10$hVw87PE934MskewKfi5bqudExL9XgZBaU8VyF2vNorZRz5hoDmPLm", "123");
        System.out.println(matches);
        System.out.println(encode);
    }

    @Test
    public void getMonth(){
        Calendar calendar = Calendar.getInstance();

//        for(int i=0;i<12;i++){

//            Date today = DateUtils.getToday();
            SimpleDateFormat sdf = new SimpleDateFormat();
//            String today1 = sdf.format(today);
//            System.out.println("今天时："+today1);
//            Date thisMonth = DateUtils.getFirstDay4ThisMonth();
//             String thisMonth1 = sdf.format(today);
//            System.out.println("本月是："+thisMonth1);
            Date thisWeek = DateUtils.getSundayOfThisWeek();
        String format = sdf.format(thisWeek);
        System.out.println("本星期是："+format);

//            Date time = calendar.getTime();
//            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//            String format = sdf.format(time);
//            System.out.println(format);
//        }

    }


    @Test
    public void test() throws Exception {
        String today = DateUtils.parseDate2String(DateUtils.getToday());
        String thisweek = DateUtils.parseDate2String(DateUtils.getThisWeekMonday());
        String thisMonth = DateUtils.parseDate2String(DateUtils.getFirstDay4ThisMonth());

        String thisMonth1 = thisMonth.substring(0, 7);

        System.out.println("今天"+today);
        System.out.println("本周"+thisweek);
        System.out.println("本月"+thisMonth1);
    }
}
